<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件对象</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background: yellow;
        }
    </style>
</head>
<body>
    <input type="text" id="username">
    <div id="box"></div>
    <script>
        username.onkeyup = function(event){
            console.log(window.event)
            console.log(event)
            if(event.keyCode == 13){
                console.log('按下了回车')
            }
        }
        box.onclick = function(event){
            console.log(event)
        }
    </script>
</body>
</html>